<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>xeokit Example</title>
    <link href="../css/pageStyle.css" rel="stylesheet"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"></script>
</head>
<body>
<input type="checkbox" id="info-button"/>
<label for="info-button" class="info-button"><i class="far fa-3x fa-question-circle"></i></label>
<canvas id="myCanvas"></canvas>
<div class="slideout-sidebar">
    <img class="info-icon" src="../../assets/images/gltf_logo.png"/>
    <h1>GLTFLoaderPlugin</h1>
    <h1>Loading multiple glTF models</h1>
    <h3>Components used</h3>
    <ul>
        <li>
            <a href="../../docs/class/src/viewer/Viewer.js~Viewer.html"
               target="_other">Viewer</a>
        </li>
        <li>
            <a href="../../docs/class/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js~GLTFLoaderPlugin.html"
               target="_other">GLTFLoaderPlugin</a>
        </li>
    </ul>
    <h3>Assets</h3>
    <ul>
        <li>
            <a href="http://openifcmodel.cs.auckland.ac.nz/Model/Details/305" target="_other">Model source</a>
        </li>
    </ul>
</div>
</body>
<script type="module">

    //------------------------------------------------------------------------------------------------------------------
    // Import the modules we need for this example
    //------------------------------------------------------------------------------------------------------------------

    import {Viewer, GLTFLoaderPlugin} from "../../dist/xeokit-sdk.min.es.js";

    //------------------------------------------------------------------------------------------------------------------
    // Create a Viewer and arrange camera
    //------------------------------------------------------------------------------------------------------------------

    const viewer = new Viewer({
        canvasId: "myCanvas",
        transparent: true
    });

    viewer.camera.orbitPitch(20);

    //----------------------------------------------------------------------------------------------------------------------
    // Load model and fit it to view
    //----------------------------------------------------------------------------------------------------------------------

    const gltfLoader = new GLTFLoaderPlugin(viewer);

    const structure = gltfLoader.load({
        id: "structure",
        src: "../../assets/models/gltf/WestRiverSideHospital/structure.gltf",
        metaModelSrc: "../../assets/models/xkt/v2/WestRiverSideHospital/structure.json",
        edges: true
    });

    structure.on("loaded", function () {

        const electrical = gltfLoader.load({
            id: "electrical",
            src: "../../assets/models/gltf/WestRiverSideHospital/electrical.gltf",
            metaModelSrc: "../../assets/models/xkt/v2/WestRiverSideHospital/electrical.json",
            edges: true
        });

        electrical.on("loaded", function () {
            const fireAlarms = gltfLoader.load({
                id: "fireAlarms",
                src: "../../assets/models/gltf/WestRiverSideHospital/fireAlarms.gltf",
                metaModelSrc: "../../assets/models/xkt/v2/WestRiverSideHospital/fireAlarms.json",
                edges: true
            });

            fireAlarms.on("loaded", function () {
                const sprinklers = gltfLoader.load({
                    id: "sprinklers",
                    src: "../../assets/models/gltf/WestRiverSideHospital/sprinklers.gltf",
                    metaModelSrc: "../../assets/models/xkt/v2/WestRiverSideHospital/sprinklers.json",
                    edges: true
                });

            });
        });
    });


    structure.on("loaded", () => {
        viewer.cameraFlight.jumpTo(structure);
    });

</script>
</html>